package scheduler.fixtures;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import se392.ateam2006.meetingmgmt.MeetingMgmtRemote;
import se392.ateam2006.resourcemgmt.ResourceMgmtRemote;
import se392.ateam2006.resourcemgmt.participant.ParticipationEntity;
import se392.ateam2006.user.UserMgmtRemote;

/**
 * Tests for retrieving and formatting Participant entities. 
 * @author Ateam (Matthew Bennett, Claire Melton, Shingai Manyiwa, John Adderley)
 * @version 25/03/07
 */
public class ParticipantsForMeeting extends fit.RowFixture{
    
    private MeetingMgmtRemote meetings;
    private ResourceMgmtRemote resources;
    private String meetingId;
    private boolean active;
    private boolean confirmed;
    
    /** Creates a new instance of ParticipantsForMeeting */
    public ParticipantsForMeeting(ResourceMgmtRemote resources, MeetingMgmtRemote meetings, String meetingId) {
        this.meetings = meetings;
        this.resources = resources;
        this.meetingId = meetingId;
        this.active = active;
        this.confirmed = confirmed;
    }
    
    public Object[] query() throws Exception{
        ArrayList participationList= new ArrayList();
        Collection <ParticipationEntity> tmpParticipants = resources.getMeetingParticipants(meetings.findMeetingById(this.meetingId));
//        //Collection <ParticipationEntity> tmpParticipants = meetings.findMeetingById(this.meetingId).getParticipants();
//       
        for (ParticipationEntity participant : tmpParticipants) {
            participationList.add(
                    new ParticipantShell(participant.getUserEntity().getEmail(), participant.isActive(), participant.isConfirmed())
                    );
        }

        return participationList.toArray();
    }
    
    public Class getTargetClass() {
        return ParticipantShell.class;
    }
    
}
